package com.fage.configuration;

import com.fage.pojo.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @author lin
 * @version 1.0
 * @date 2020-08-10 17:16
 * @Description TODO
 */
@Configuration
@PropertySource(value = {"classpath:user/user.properties"})
public class UserConfigs {
    @Value("${id}")
    int id;
    @Value("${name}")
    String name;
    @Value(("${age}"))
    int age;

    @Bean(value = "user2")
    public User createUser1() {
        return new User(id, name, age, 50);
    }

    public static void main(String[] args) throws ParseException {
        Calendar calendar = Calendar.getInstance();
        Date date = new Date();
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        Date parse = sdf.parse("2020-08-01");
        calendar.setTime(parse);
        System.out.println(calendar.get(Calendar.MONTH));

    }

}
